package tpdisenio2009.model.beans;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author DeuterioX
 */
@Entity
@Table(name = "fantasy_team_player")
@NamedQueries({
    @NamedQuery(name = "FantasyTeamPlayer.findAll", query = "SELECT f FROM FantasyTeamPlayer f")})
public class FantasyTeamPlayer implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String TITULAR_ROLE = "Titular";
    public static final String SUBSTITUTE_ROLE = "Suplente";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;

    @Basic(optional = false)
    @Column(name = "begin_date", nullable=false)
    @Temporal(TemporalType.DATE)
    private Date beginDate;

    @Basic(optional = true)
    @Column(name = "end_date")
    @Temporal(TemporalType.DATE)
    private Date endDate;

    @Basic(optional = false)
    @Column(name = "rol", nullable=false)
    private String rol;

    @JoinColumn(name = "id_fantasy_team", referencedColumnName = "id", nullable=false)
    @ManyToOne(optional = false)
    private FantasyTeam fantasyTeam;

    @JoinColumn(name = "id_soccer_player", referencedColumnName = "id", nullable=false)
    @ManyToOne(optional = false)
    private SoccerPlayer soccerPlayer;

    public FantasyTeamPlayer() {
    }

    public FantasyTeamPlayer(Integer id) {
        this.id = id;
    }

    public FantasyTeamPlayer(Integer id, Date beginDate, Date endDate, String rol) {
        this.id = id;
        this.beginDate = beginDate;
        this.endDate = endDate;
        this.rol = rol;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getRol() {
        return rol;
    }

    public void setRol(String rol) {
        this.rol = rol;
    }

    public FantasyTeam getFantasyTeam() {
        return fantasyTeam;
    }

    public void setFantasyTeam(FantasyTeam fantasyTeam) {
        this.fantasyTeam = fantasyTeam;
    }

    public SoccerPlayer getSoccerPlayer() {
        return soccerPlayer;
    }

    public void setSoccerPlayer(SoccerPlayer soccerPlayer) {
        this.soccerPlayer = soccerPlayer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FantasyTeamPlayer)) {
            return false;
        }
        FantasyTeamPlayer other = (FantasyTeamPlayer) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tpdisenio2009.model.beans.FantasyTeamPlayer[id=" + id + "]";
    }

}
